// pages/dispatch/receive/index/index.js
import {
  getOrderList,
  orderRefund,
  getOrderListV2
} from '../../../../utils/api/index.js'
import moment from '../../../../utils/moment.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLogin: true,
    companyArray:['公司1','公司2'],
    selCompany:{
      companyName: '切分公司'
    },
    selete2Arr: ['全部','A1','A2'],
    selete2Name: '切果品',
    selete3Arr: ['地区1','地区2'],
    selete3Name: '切站点',
    paihangChange:'PRINTED',
    swdata:[  {
      zhandian:"果满园",
      liuxiang:"2,233",
      ziti:"2,233",
      zaipei:"3",
      wuliu:"圆通速递"
    },
    {
      zhandian:"果满园",
      liuxiang:"2,233",
      ziti:"2,233",
      zaipei:"3",
      wuliu:"圆通速递"
    },{
      zhandian:"果满园",
      liuxiang:"2,233",
      ziti:"2,233",
      zaipei:"3",
      wuliu:"圆通速递"
    },
    {
      zhandian:"果满园",
      liuxiang:"2,233",
      ziti:"2,233",
      zaipei:"3",
      wuliu:"圆通速递"
    },{
      zhandian:"果满园",
      liuxiang:"2,233",
      ziti:"2,233",
      zaipei:"3",
      wuliu:"圆通速递"
    },
    {
      zhandian:"果满园",
      liuxiang:"2,233",
      ziti:"2,233",
      zaipei:"3",
      wuliu:"圆通速递"
    },{
      zhandian:"果满园",
      liuxiang:"2,233",
      ziti:"2,233",
      zaipei:"3",
      wuliu:"圆通速递"
    }],
    
    active: 'receive',
    lanshou_active: 0,
    tabactive: 'all',
    date: '2024-03-05',//默认起始时间  
    date2: '2024-03-05',//默认结束时间 
    show: false 
  },
  changeTab(event) {
    this.setData({
      lanshou_active: event.detail.index, 
    })
    console.log(event)
      wx.showToast({
        title: `切换到标签 ${event.detail.title}`,
        icon: 'none',
      });
    
  },
  // 切换公司
  changeCompany(e) {
    console.log(e)
    let index = e.detail.value
    this.setData({
      fruitId: undefined,
      selCompany:{
        companyName: this.data.companyArray[index]
      },
    })
  },
  changeCompany2(e) {
    console.log(e)
    let index = e.detail.value
    this.setData({
      selete2Name: this.data.selete2Arr[index]
    })
  },
  changeCompany3(e) {
    console.log(e)
    let index = e.detail.value
    this.setData({
      selete3Name: this.data.selete3Arr[index]
    })
  },
  onChange(event) {

    switch ( event.detail){
      case 'tongji':
        wx.redirectTo({ 
          url: '/pages/dispatch/tongji/index'
        });
        break;
        case 'order':
          wx.redirectTo({ 
            url: '/pages/dispatch/order/index'
          });
          break;
          case 'dispatch':
            wx.redirectTo({ 
              url: '/pages/dispatch/dispatchManage/index/index'
            });
            break;
            case 'receive':
              wx.redirectTo({ 
                url: '/pages/dispatch/receive/index/index'
              });
              break;
              case 'mine':
                wx.redirectTo({ 
                  url: '/pages/dispatch/mine/index/index'
                });
                break;
    } 
    this.setData({ active: event.detail });
  },
  changeAll(e) { 
    console.log(e)
    this.setData({
      tabactive: e.target.dataset.self,
    })
  },
  paihangChange(e) { 
    console.log(e)
    this.setData({
      paihangChange: e.target.dataset.self,
    })
  },
  onDisplay() { 
    this.setData({ show: true }); 
  },
  onSerch() {
    this.setData({ show: false });
  },
  toLogin() {
    wx.navigateTo({
      url: '/pages/mine/login/index',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})